package ZuoYe1;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class Test4 {

	public static void main(String[] args) throws IOException {
		ZipOutputStream zipos = new ZipOutputStream(
				new FileOutputStream("d://2.zip"));

		for(int i=1;i<=34;i++){
			ZipEntry ze1 = new ZipEntry(i+".jpg");

			FileInputStream fis = 
					new FileInputStream("d://1/"+i+".jpg");
			zipos.putNextEntry(ze1);

			byte[] b = new byte[1024];
			int num;

			while((num=fis.read(b))!=-1){
				zipos.write(b,0,num);
			}
			fis.close();
		}

		zipos.closeEntry();
		zipos.close();

	}

}
